package org.sems.sems.Mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.sems.sems.entity.Zphgwdyk;

import java.util.List;
import java.util.Map;

@Mapper
public interface ZphgwdykMapper {

            @Select("""
            SELECT 
                b.*, 
                c.XLMC, 
                d.SFMC, 
                e.FLMC, 
                f.YHXM, 
                g.GSMC 
            FROM zphgwdyk a  
            LEFT JOIN DATA_GWDMK b ON a.GWDM = b.ID 
            LEFT JOIN XLTTK c ON b.ZDXLYQ = c.ID 
            LEFT JOIN SFDMK d ON b.GZSF = d.SFDM 
            LEFT JOIN GWFLK e ON b.GWFL = e.ID 
            LEFT JOIN DWYHK f ON b.FBZ = f.YHM AND b.FBZYHSFDM = 3 
            LEFT JOIN DATA_DWDMK g ON b.DWDM = g.DWDM 
            WHERE a.ZPHDM = #{zphdm}
        """)
    List<Map<String, Object>> selectByZPHDM(int zphdm);

    @Insert("INSERT INTO zphgwdyk (GWDM, ZPHDM) VALUES (#{gwdm}, #{zphdm})")
    int insertNewZPHGWDYK(Zphgwdyk zphgwdyk);
}
